
app:registClass("DynastyBattleController", "app.dynastyBattle.controllers.DynastyBattleController")
app:registClass("DynastyMapController", "app.dynastyBattle.controllers.DynastyMapController")

app:registInst(import(".models.DynastyBattleModel").new())
app:registInst(import(".models.DynastyMapModel").new())

app:registInst(app:getClass("DynastyBattleController").new({type="systemUI"}))
app:registInst(app:getClass("DynastyMapController").new({type="world", zOrder=SceneZOrder.desktopZOrder}))


app.session:on("pb_town.S2C_EnterTownWar", function(msg)
	print("S2C_EnterTownWar")
	app:sendMsg("DynastyBattleModel", "onEnterTownWar", msg)
end)

app.session:on("pb_town.S2C_TownWarSettlement", function(msg)
	print("S2C_TownWarSettlement")
	app:sendMsg("DynastyBattleModel", "onDynastyBattleAccount", msg)
	if msg.oldOwnerGuildId ~= msg.newOwnerGuildId then 
		EM:notify("S2C_TownWarSettlement", msg)
	end
end)

-- 登陆、准备、结束 ，服务器下发 城镇状态
app.session:on("pb_town.S2C_TownPhaseNotify", function(msg)
	print("S2C_TownPhaseNotify")
	app:sendMsg("DynastyBattleModel", "onTownPhaseNotify", msg)
end)

